package io.shallwe.history;

import com.jfinal.aop.Inject;
import com.jfinal.kit.Ret;
import io.shallwe.common.controller.BaseController;
import io.shallwe.common.model.Toc;

import java.util.List;

/**
 * @Description: 参数设置上下限
 * @author: gkw
 * @description: io.shallwe.history
 * @date:2019/11/19
 **/
public class LogTocController extends BaseController {

    @Inject
    LogTocService tocService;

    public void index(){
        render("index.html");
    }

    /**
     * @Description:  参数设置页列表信息
     * @param:  []
     * @return: void
     * @author : gkw
     */
    public void list(){
        Integer offset = getParaToInt("offset",1);
        String remark = get("remark");
        renderJson(tocService.configPagenate(offset,remark));
    }

    public void edit(){
        Integer id = getParaToInt("id");
        Toc toc = tocService.findById(id);
        setAttr("toc",toc);
        render("add_edit.html");
    }

    public void update(){
        Integer id = getParaToInt("id");
        Float maxValue = Float.valueOf(getPara("parameter_max_value"));
        Float minValue = Float.valueOf(getPara("parameter_min_value"));
        renderJson(tocService.update(id,maxValue,minValue));
    }

    /**
     * @Description:   参数为有效
     * @param:  []
     * @return: void
     * @author : gkw
     */
    public void doControl(){
        Integer id = getParaToInt("id");
        renderJson(tocService.doControl(id));
    }

    /**
     * @Description:  参数为无效
     * @param:  []
     * @return: void
     * @author : gkw
     */
    public void notControl(){
        Integer id = getParaToInt("id");
        renderJson(tocService.notControl(id));
    }
}
